package vn.fpt.fsoft.user.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LogonForm extends ActionForm {
	private static final long serialVersionUID = -4975629043707066909L;
	private String userId;
	private String pwd;
	

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}


	@Override
	public ActionErrors validate(ActionMapping mapping,
	HttpServletRequest request) {
 
	    ActionErrors errors = new ActionErrors();
 
	    if( getUserId() == null || ("".equals(getUserId()))) {
	       errors.add("user.err.username",
              new ActionMessage("user.err.username.required"));
	    }
	    
	    if( getPwd() == null || ("".equals(getPwd()))) {
		   errors.add("user.err.password",
	           new ActionMessage("user.err.password.required"));
		}
	    
	    return errors;
	}
 
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		// reset properties
		userId = "";
		pwd = "";
	}
	
}
